#pragma once

#include <map>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "Sprite.h"

using namespace std;

class TextureManager 
{
public:
	virtual ~TextureManager();

	static TextureManager* Instance()              
	{                                              
		if (s_pInstance == 0)                 
		{                                           
			s_pInstance = new TextureManager();    
		}                                           

		return s_pInstance;                        
	}

	//Methods
	
	//Load the image with the fileName, and assigns an id.
	bool load(std::string fileName, std::string id, SDL_Renderer* pRenderer);
	
	// ??
	void add(Sprite _sprite, SDL_Renderer* pRenderer);
	//draw the static image.
	void draw(std::string id, int x, int y, int width, int height,
		SDL_Renderer* pRenderer, SDL_RendererFlip = SDL_FLIP_NONE);

	//
	void drawParallax(Sprite _sprite, int &_idSprite,
		SDL_Renderer* pRenderer, SDL_RendererFlip = SDL_FLIP_NONE);

	//draw image sprite
	void drawFrame(std::string id, int x, int y, int width, int height,
		int currentRow, int currentFrame, 
		SDL_Renderer* pRenderer, SDL_RendererFlip flip = SDL_FLIP_NONE); 

	void clearFromTextureMap(std::string id); //delete SDL_Texture from the map

	map<string, SDL_Texture*> GetBoundingBox();

protected:
private:

	Sprite m_sprite;

	SDL_Texture* m_textureSprite;
	map<string, SDL_Texture*> m_textureMap; //map with all the SDL_Textures
	TextureManager(); //now is a SINGLETON
	

	static TextureManager* s_pInstance; // Now in GOD-MODE SINGLETON
};

typedef TextureManager TheTextureManager;//Owned SINGLETON